<?php
session_start();
require_once 'inc/global.php';
if (isset($_GET['p']))
$pid = $_GET['p'];
if ($_SESSION['UserId'])
$uid = $_SESSION['UserId'];
function cartoutput ($uid)
{
	$conn = getConnection($uid);
	$co = $conn->query("SELECT * 
FROM `shoppingcart` cs
JOIN Products pd
WHERE pd.id = cs.pd_id AND cs.Session_id = $uid
	");
	$conn->close();
	return $co;
}
$co = cartoutput($uid);
	include('inc/header.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Shopping Cart</title>
</head>

<body>
<?php
	include('inc/login.php');
	include('inc/nav.php');
?>
<div class="contentstuff">
<h1>Your Orders</h1>
<table>
<tr>
<td><h2>Order Number</h2></td>
<td><h2>Product Name</h2></td>
<td><h2>Amount Ordered</h2></td>
<td><h2>Price</h2></td>
<td><h2>Delete</h2></td>
</tr>
<? 
$count = 0;
while ($coo = $co->fetch_assoc()){
	$count = $count + 1;
	 ?>
<tr><td><?=$count?></td>
<td><?=$coo['product_name']?></td>
<td><?=$coo['qty']?></td>
<td><?=$coo['price']*$coo['qty']?></td>
<td><a href="cart.php?d=<?=$coo['odid']?>">Delete</a></td>
</tr>
<? } ?>
</table>
</div>
</body>
</html>